/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrmCalculadoraMascara.java
 *
 * Created on 30/09/2011, 10:47:39
 */
package calculadora.storyteller.vampiro;

import javax.swing.SpinnerNumberModel;
import model.CalculadoraDeExperiencia;
import org.jdesktop.swingx.combobox.EnumComboBoxModel;

/**
 *
 * @author yurifw
 **/
public class FrmCalculadoraMascara extends javax.swing.JInternalFrame {
    CalculadoraDeExperiencia calculadora;
    public FrmCalculadoraMascara() {
        super("Calculadora de Experiencia - A Mascara",true, true, false);
        initComponents();
        calculadora = new CalculadoraDeExperiencia(new CustoAtributo());
        cboAreaFicha.setModel(new EnumComboBoxModel(CalculaExperiencia.Areas.class));
        spnQuantosComprar.setModel(new SpinnerNumberModel(1, 1, 99, 1));
        spnNivelAtual.setModel(new SpinnerNumberModel(0, 0, 99, 1));
    }
    


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblAreaFicha = new javax.swing.JLabel();
        cboAreaFicha = new javax.swing.JComboBox();
        lblNivelAtual = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        btoCalcular = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtHistorico = new javax.swing.JTextArea();
        lblTotalGasto = new javax.swing.JLabel();
        lblTotalGasto2 = new javax.swing.JLabel();
        spnQuantosComprar = new javax.swing.JSpinner();
        spnNivelAtual = new javax.swing.JSpinner();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Calculadora de Experiencia - A Mascara");

        lblAreaFicha.setText("Selecione onde deseja gastar a experiencia:");

        cboAreaFicha.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Atributo", "Habilidade", "Disciplina de Clã", "Outras Disciplinas", "Trilha Secundária", "Virtude", "Humanidade", "Força de Vontade", "Disciplina para Caitiff" }));
        cboAreaFicha.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cboAreaFichaItemStateChanged(evt);
            }
        });
        cboAreaFicha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboAreaFichaActionPerformed(evt);
            }
        });

        lblNivelAtual.setText("Digite o nivel atual do atributo:");

        jLabel1.setText("Digite quantos pontos deseja comprar:");

        btoCalcular.setText("Calcular");
        btoCalcular.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btoCalcularActionPerformed(evt);
            }
        });

        txtHistorico.setColumns(20);
        txtHistorico.setRows(5);
        jScrollPane1.setViewportView(txtHistorico);

        lblTotalGasto.setText("Total Gasto:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lblAreaFicha)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cboAreaFicha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(lblNivelAtual))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(spnNivelAtual, javax.swing.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
                            .addComponent(spnQuantosComprar)))))
            .addGroup(layout.createSequentialGroup()
                .addGap(144, 144, 144)
                .addComponent(btoCalcular))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblTotalGasto)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblTotalGasto2)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblAreaFicha)
                    .addComponent(cboAreaFicha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblNivelAtual)
                    .addComponent(spnNivelAtual, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(spnQuantosComprar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(17, 17, 17)
                .addComponent(btoCalcular)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblTotalGasto)
                    .addComponent(lblTotalGasto2))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cboAreaFichaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboAreaFichaActionPerformed
        
}//GEN-LAST:event_cboAreaFichaActionPerformed

    private void btoCalcularActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btoCalcularActionPerformed
        int nvAtual = (int)spnNivelAtual.getValue();
        int qtosComprar = (int)spnQuantosComprar.getValue();
        calculadora.calcularExperiencia(nvAtual, qtosComprar);
        txtHistorico.setText(calculadora.getHistorico().toString());
        lblTotalGasto2.setText(calculadora.getTotalExperienciaGasta()+"");        
    }//GEN-LAST:event_btoCalcularActionPerformed

    private void cboAreaFichaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboAreaFichaItemStateChanged
        switch((CalculaExperiencia.Areas)cboAreaFicha.getSelectedItem()){
            case ATRIBUTO:
                calculadora.setTipoDeCalculo(new CustoAtributo());
                break;
            case DISCIPLINA_CAITIFF:
                calculadora.setTipoDeCalculo(new CustoDisciplinaCaitiff());
                break;
            case DISCIPLINA_DE_CLA:
                calculadora.setTipoDeCalculo(new CustoDisciplinaDeCla());
                break;
            case FORCA_DE_VONTADE:
                calculadora.setTipoDeCalculo(new CustoForcaDeVontade());
                break;
            case HABILIDADE:
                calculadora.setTipoDeCalculo(new CustoHabilidade());
                break;
            case HUMANIDADE:
                calculadora.setTipoDeCalculo(new CustoHumanidade());
                break;
            case OUTRAS_DISCIPLINAS:
                calculadora.setTipoDeCalculo(new CustoOutrasDisciplinas());
                break;
            case TRILHA_SECUNDARIA:
                calculadora.setTipoDeCalculo(new CustoTrilhaSecundaria());
                break;
            case VIRTUDE:
                calculadora.setTipoDeCalculo(new CustoVirtude());
                break;
        }
    }//GEN-LAST:event_cboAreaFichaItemStateChanged
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FrmCalculadoraMascara().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btoCalcular;
    private javax.swing.JComboBox cboAreaFicha;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblAreaFicha;
    private javax.swing.JLabel lblNivelAtual;
    private javax.swing.JLabel lblTotalGasto;
    private javax.swing.JLabel lblTotalGasto2;
    private javax.swing.JSpinner spnNivelAtual;
    private javax.swing.JSpinner spnQuantosComprar;
    private javax.swing.JTextArea txtHistorico;
    // End of variables declaration//GEN-END:variables
}
